package org.examcity.util.beanconverter;

import org.examcity.util.beanconverter.Rule.Field;

public class RuleBuilder {

	private Rule v = new Rule();

	public RuleBuilder name(String name) {
		v.setName(name);
		return this;
	}

	public RuleBuilder from(Class<?> fromClass) {
		v.setClassA(fromClass);
		return this;
	}

	public RuleBuilder factory(Factory factory) {
		v.setFactory(factory);
		return this;
	}

	public RuleBuilder converter(Converter converter) {
		v.setConverter(converter);
		return this;
	}

	public RuleBuilder to(Class<?> toClass) {
		v.setClassB(toClass);
		return this;
	}

	public RuleBuilder field(String fromAndTo) {
		Field f = new Field();
		f.setFieldA(fromAndTo);
		f.setFieldB(fromAndTo);
		v.getFields().add(f);
		return this;
	}

	public RuleBuilder field(String from, String to) {
		Field f = new Field();
		f.setFieldA(from);
		f.setFieldB(to);
		v.getFields().add(f);
		return this;
	}

	public Rule build() {
		return v;
	}
}
